﻿<Page x:Class="GYMm.UI.Views.DashboardView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:Controls="using:Common.UI.Controls"
      xmlns:Converters="using:Common.UI.Converters"
      xmlns:VM="using:GYM.UI.ViewModels"
      xmlns:cal="using:Caliburn.Micro"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="using:GYM.UI.Views"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      x:Name="MainPage"
      NavigationCacheMode="Enabled"
      mc:Ignorable="d">

    <Page.Resources>
        <Converters:StringToObjectConverter x:Name="ExerciseNameToStringConverter" Default="LONG TAP TO SET EXERCISE NAME" />
    </Page.Resources>

    <Page.Background>
        <ImageBrush ImageSource="ms-appx:///Assets/blue-gradient-wallpaper.jpg" Stretch="UniformToFill" />
    </Page.Background>

    <Grid>

        <ProgressBar VerticalAlignment="Top"
                     IsIndeterminate="True"
                     Visibility="{Binding ShowProgress,
                                          Converter={StaticResource DirectBoolToVisibilityConverter}}" />

        <Grid Grid.Column="0">
            <Controls:CustomGridView x:Name="MainGrid"
                                     Margin="10"
                                     HorizontalAlignment="Stretch"
                                     VerticalAlignment="Stretch"
                                     AllowDrop="True"
                                     CanDragItems="True"
                                     IsItemClickEnabled="True"
                                     ItemClick="OnItemClicked"
                                     ItemsSource="{Binding Items,
                                                           Mode=TwoWay}"
                                     ManipulationMode="All"
                                     ReorderMode="Disabled"
                                     ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                                     Visibility="{Binding NoExercises,
                                                          Converter={StaticResource ReverceBoolToVisibilityConverter}}">


                <Controls:CustomGridView.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="2"
                              HorizontalAlignment="Stretch"
                              VerticalAlignment="Stretch"
                              Background="#3FFFFFFF"
                              Holding="Grid_Holding"
                              Loaded="Grid_Loaded"
                              RightTapped="Grid_RightTapped">

                            <StackPanel HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Visibility="{Binding IsEmpty,
                                                             Converter={StaticResource DirectBoolToVisibilityConverter}}">

                                <TextBlock HorizontalAlignment="Center"
                                           FontSize="{StaticResource MiddleFontSize}"
                                           Foreground="White"
                                           Text="{Binding ExerciseDisplayName,
                                                          Converter={StaticResource ExerciseNameToStringConverter}}"
                                           TextAlignment="Center"
                                           TextWrapping="Wrap" />

                                <TextBlock HorizontalAlignment="Center"
                                           FontSize="{StaticResource MiddleFontSize}"
                                           FontWeight="Bold"
                                           Foreground="White"
                                           Text="TAP TO START YOUR FIRST WORKOUT"
                                           TextAlignment="Center"
                                           TextWrapping="Wrap" />
                            </StackPanel>

                            <Grid Visibility="{Binding IsEmpty, Converter={StaticResource ReverceBoolToVisibilityConverter}}">

                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                    <RowDefinition Height="2*" />
                                    <RowDefinition />
                                </Grid.RowDefinitions>

                                <TextBlock Margin="0,5,0,0"
                                           HorizontalAlignment="Center"
                                           VerticalAlignment="Center"
                                           FontSize="{StaticResource MiddleFontSize}"
                                           Foreground="White"
                                           Text="{Binding ExerciseDisplayName,
                                                          Converter={StaticResource ExerciseNameToStringConverter}}"
                                           TextAlignment="Center"
                                           TextWrapping="Wrap" />

                                <Grid Grid.RowSpan="3"
                                      HorizontalAlignment="Stretch"
                                      VerticalAlignment="Stretch">

                                    <!--
										<Grid.Projection>
										<PlaneProjection RotationY="0" />
										</Grid.Projection>
									-->

                                    <StackPanel HorizontalAlignment="Center"
                                                VerticalAlignment="Center"
                                                Orientation="Horizontal">

                                        <TextBlock VerticalAlignment="Bottom"
                                                   FontSize="{StaticResource SuperLargeFontSize}"
                                                   Foreground="White"
                                                   Text="{Binding Weight}"
                                                   TextAlignment="Center" />

                                        <TextBlock VerticalAlignment="Top"
                                                   FontSize="{StaticResource LargeFontSize}"
                                                   Foreground="White"
                                                   Text="{Binding MaxWeight}"
                                                   TextAlignment="Center"
                                                   Visibility="{Binding IsRecordDisplayed,
                                                                        Converter={StaticResource DirectBoolToVisibilityConverter}}" />

                                        <Path Width="50"
                                              Height="50"
                                              HorizontalAlignment="Left"
                                              VerticalAlignment="Center"
                                              Data="M137.709,33.615 L137.709,36.253 C135.679,36.763 133.999,38.501 132.571,41.115 C127.319,71.175 124.209,85.798 122.293,91.809 C127.496,82.9453 132.934,75.2245 138.543,68.337 C145.765,57.92 150.541,49.548 150.626,43.615 C149.787,37.532 145.667,34.051 137.709,33.615 z M31.182,33.059 L23.2649,35.281 C18.2489,39.1 17.5379,43.939 19.6539,49.448 C20.4349,52.701 24.6559,59.755 33.404,71.809 C39.74,79.6289 44.0904,86.1083 46.876,91.531 C43.195,75.914 39.827,59.449 36.737,42.226 C36.02,38.838 34.131,36.654 31.182,35.559 z M152.792,0.000287 C154.049,-0.008149 155.328,0.168977 156.598,0.55975 C163.821,2.91992 166.876,10.403 168.682,18.6153 C173.85,41.4408 155.979,64.5953 130.973,87.8518 C126.526,91.4877 123.67,95.2856 123.057,99.3095 C123.327,102.673 126.805,104.172 133.161,103.996 C136.39,104.413 136.702,108.788 133.577,110.142 C131.145,110.999 128.446,110.996 125.452,110.038 C122.235,107.686 120.611,103.719 120.452,98.2676 C114.827,112.329 105.021,120.558 90.4877,122.226 C90.2597,131.869 94.5066,137.5 102.536,141.185 C106.862,141.778 109.465,143.865 109.515,148.163 C94.9186,164.516 88.7146,186.168 89.9316,212.503 C90.6456,224.385 94.2336,232.933 99.9316,239.03 C107.997,246.182 112.944,255.16 114.932,265.871 L125.765,266.392 L125.765,299.205 L42.8478,299.413 L42.7088,265.976 L54.0948,265.84 C55.8368,255.76 60.3548,247.069 67.5668,239.728 C74.0718,235.081 77.9026,225.86 79.2366,212.365 C79.9166,183.747 73.1097,162.471 59.3068,148.058 C59.9468,144.255 63.005,141.79 66.703,141.323 C74.8389,137.53 77.8426,131.211 78.0566,122.121 C64.6268,120.8 54.5118,113.448 48.4728,98.6835 C48.3628,106.014 45.5248,110.283 39.4108,110.871 C35.6558,111.329 33.4478,110.042 33.0558,106.704 C33.5938,104.542 36.1628,103.583 40.3478,103.579 C44.2958,103.45 45.8448,101.588 45.6608,98.4755 C45.2868,96.0416 44.1948,93.8946 42.4318,92.0167 L33.5768,84.1009 C14.026,65.9653 -0.827223,46.7057 0.035773,23.6842 C0.990275,10.4515 6.80596,0.662741 16.0769,0.246764 C24.3988,0.440761 29.0448,4.85365 29.9318,13.5805 C27.0968,23.1663 20.7149,26.5892 10.453,23.2682 C10.408,30.1041 17.4459,32.651 31.2858,31.0801 L31.1818,28.3711 L137.64,28.4761 L137.571,30.8371 C151.59,32.625 158.057,30.1421 157.849,23.6842 C146.911,26.4232 140.53,22.5466 139.515,11.9485 C139.548,4.73528 145.662,-0.77353 152.792,0.000287 z"
                                              Fill="White"
                                              Stretch="Uniform"
                                              StrokeThickness="0"
                                              UseLayoutRounding="False"
                                              Visibility="{Binding IsCupDisplayed,
                                                                   Converter={StaticResource DirectBoolToVisibilityConverter}}" />

                                        <!--
											<Path Width="30"
											Height="50"
											HorizontalAlignment="Left"
											VerticalAlignment="Bottom"
											Data="M14.3117,89.861 C5.66932,101.491 5.2174,117.088 10.9787,135.695 C16.4037,154.767 29.8232,174.22 50.667,194.028 C43.008,171.634 39.5436,150.726 39.7289,131.111 C30.8123,132.151 24.286,128.683 20.8746,119.34 C19.6226,114.747 21.6873,110.975 26.917,107.986 z M149.729,89.445 C145.745,96.4418 141.572,102.635 137.229,108.091 C144.313,111.974 145.488,117.017 141.396,123.092 C136.576,129.445 130.798,132.264 124,131.322 C124.385,153.228 120.599,174.041 113.271,193.924 C135.682,174.772 151.007,151.178 156.5,121.424 C158.354,107.892 156.67,96.8328 149.729,89.445 z M82.0901,0 C90.9861,0.651003 96.2581,5.58702 97.507,15.2781 C97.446,23.5011 93.1181,28.7451 84.8681,31.2501 C85.4941,35.7391 90.0441,38.1711 96.5351,39.5841 C102.898,41.4011 105.667,45.2781 105.146,54.3402 C107.588,55.6102 108.184,56.6512 105.701,58.4722 C97.194,66.9922 94.3771,76.8533 96.0831,87.7783 C100.239,98.5063 106.667,105.113 116.187,109.34 C122.541,109.549 124.244,110.055 124.416,116.632 L124.312,118.715 C126.187,118.507 127.192,120.116 126.812,121.631 C126.896,123.185 126.252,124.373 124.625,125.069 L124.833,126.528 C130.976,127.284 135.369,125.018 138.271,120.173 C139.343,118.55 139.323,116.682 137.646,114.444 L132.541,111.735 C131.319,110.834 130.81,109.655 131.291,108.09 C134.543,99.2213 139.038,90.4913 145.146,81.9442 C147.82,79.5782 150.494,79.7923 153.167,81.8403 C166.81,100.296 167.065,122.684 155.979,148.402 C146.101,169.61 132.128,186.625 114.868,200.278 C113.329,201.589 111.857,202.194 110.458,202.049 C106.764,210.37 102.604,218.291 97.958,225.799 C99.424,226.223 99.945,227.078 98.863,228.5 C90.8751,242.257 95.8751,245.591 105.145,252.257 C108.824,255.206 110.561,258.504 110.354,262.153 C110.746,264.132 111.817,265.114 113.375,265.382 C115.387,266.457 115.869,266.483 116.083,269.028 C116.225,270.976 117.055,271.807 118.375,271.841 C120.054,272.759 120.123,274.178 119.208,275.903 L139.312,276.528 L139.034,325.972 L24.7287,325.972 L24.4509,276.389 L44.9372,276.007 C43.681,274.008 43.8847,272.412 46.2914,271.424 C47.3585,271.423 48.0085,270.735 48.1664,269.237 C47.8508,267.299 48.717,265.909 50.7705,265.07 C52.6652,264.784 53.7873,263.396 54.2081,261.007 C54.4018,257.267 56.3231,254.224 59.6247,251.737 C70.7706,243.716 71.604,238.82 65.5623,229.237 C64.5322,227.347 64.8222,226.273 66.0831,225.799 C61.5051,218.482 57.4495,210.616 53.8956,202.223 C52.9615,202.557 51.5192,202.611 49.9373,201.216 C33.6873,187.362 18.9864,171.265 9.17331,150.555 C-2.79056,126.288 -3.36946,103.697 9.31261,83.0563 C12.5497,79.0912 15.6904,78.9223 18.7571,81.6673 C24.5384,89.3783 29.1735,98.0223 32.7848,107.5 C33.8493,109.725 33.2987,111.278 30.8751,112.049 C26.2124,114.175 24.0293,116.626 25.8404,120.139 C28.7389,125.597 33.2594,127.514 39.1736,126.389 L39.1736,124.583 C36.1875,123.403 36.1875,119.549 39.7292,118.507 L40.1459,112.917 C40.738,110.618 42.5527,109.516 45.5625,109.583 C56.8625,106.592 64.3108,98.8793 68.2014,86.8063 C70.1421,76.4653 66.8432,66.9092 57.9236,58.1952 C56.6367,56.3052 57.0943,55.0892 59.0348,54.4452 C58.8959,46.9451 59.0695,41.4931 70.0416,39.1321 C75.7491,37.3111 79.2361,34.6911 80.2851,30.9721 C72.6719,29.8701 67.8074,24.8121 66.5348,14.5841 C68.5064,5.69603 73.6549,0.789004 82.0901,0 z"
											Fill="White"
											Stretch="Uniform"
											StrokeThickness="0"
											UseLayoutRounding="False"
											Visibility="{Binding IsRecordVolumeWorkout,
											Converter={StaticResource DirectBoolToVisibilityConverter}}" />
										-->

                                    </StackPanel>

                                </Grid>

                                <TextBlock Grid.Row="2"
                                           HorizontalAlignment="Center"
                                           VerticalAlignment="Center"
                                           FontSize="{StaticResource MiddleFontSize}"
                                           Foreground="White"
                                           Text="{Binding Date,
                                                          Converter={StaticResource DateTimeToStringConverter}}"
                                           TextAlignment="Center" />

                            </Grid>

                        </Grid>
                    </DataTemplate>
                </Controls:CustomGridView.ItemTemplate>

                <Controls:CustomGridView.Resources>
                    <Style TargetType="GridViewItem">
                        <Setter Property="AllowDrop" Value="True" />
                        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                        <Setter Property="VerticalContentAlignment" Value="Stretch" />
                        <Setter Property="Margin" Value="0" />
                    </Style>
                </Controls:CustomGridView.Resources>
            </Controls:CustomGridView>

            <TextBlock HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       FontSize="{StaticResource LargeFontSize}"
                       Foreground="White"
                       Text="CREATE A LIST OF EXERCISES"
                       TextAlignment="Center"
                       Visibility="{Binding NoExercises,
                                            Converter={StaticResource DirectBoolToVisibilityConverter}}" />







        </Grid>

    </Grid>

    <Page.BottomAppBar>
        <CommandBar ClosedDisplayMode="Minimal">
            <AppBarButton x:Name="NewExerciseBtn"
                          Click="OnNewClicked"
                          Icon="Add"
                          Label="NEW">
                <AppBarButton.Flyout>
                    <Flyout Placement="Full">
                        <Flyout.FlyoutPresenterStyle>
                            <Style TargetType="FlyoutPresenter">
                                <Setter Property="Background" Value="#B2000000" />
                            </Style>
                        </Flyout.FlyoutPresenterStyle>

                        <Grid>
                            <Canvas Background="Transparent" Tapped="DialogBackTapped" />
                            <Grid Width="400"
                                  Height="230"
                                  Margin="0,40,0,0"
                                  VerticalAlignment="Top"
                                  Background="White">

                                <Button Margin="0,-10,-33,0"
                                        HorizontalAlignment="Right"
                                        VerticalAlignment="Top"
                                        BorderThickness="0"
                                        Click="OnCloseClick"
                                        Padding="0">
                                    <Path Width="20"
                                          Height="20"
                                          Margin="10"
                                          Data="M159.941,126.017 L193.676,92.1944 L159.841,58.4719 L164.76,53.6938 L198.515,87.4971 L232.25,53.6544 L236.849,58.6726 L203.214,92.1944 L236.949,125.817 L232.03,130.835 L198.395,96.9316 L164.761,130.935 z"
                                          Fill="{StaticResource GymGray}"
                                          Stretch="Fill"
                                          UseLayoutRounding="False" />
                                </Button>

                                <StackPanel Margin="20" DataContext="{Binding SelectedExercise}">

                                    <TextBlock Grid.ColumnSpan="2"
                                               Margin="0, 15"
                                               HorizontalAlignment="Center"
                                               VerticalAlignment="Center"
                                               FontSize="{StaticResource LargeFontSize}"
                                               Foreground="{StaticResource GymGray}"
                                               Text="EXERCISE" />

                                    <TextBlock Grid.Row="1"
                                               FontSize="{StaticResource SmallFontSize}"
                                               Foreground="{StaticResource GymLightGray}"
                                               Text="display name" />
                                    <TextBox x:Name="ExerciseNameBox"
                                             Grid.Row="1"
                                             VerticalAlignment="Center"
                                             BorderBrush="{StaticResource GymLightGray}"
                                             Foreground="{StaticResource GymGray}"
                                             PlaceholderText="ENTER EXERCISE NAME"
                                             Text="{Binding ExerciseDisplayName,
                                                            Mode=TwoWay}" />

                                    <!--
							<ToggleSwitch Background="{StaticResource GymLightGray}"
							IsOn="{Binding IsLarge,
							Mode=TwoWay}"
							OffContent="small icon"
							OnContent="Large icon" />
						-->
                                </StackPanel>

                                <Grid Height="35"
                                      Margin="20"
                                      VerticalAlignment="Bottom">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="10" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>

                                    <Button HorizontalAlignment="Stretch"
                                            VerticalAlignment="Stretch"
                                            Background="{StaticResource GymLightGray}"
                                            BorderBrush="{StaticResource GymLightGray}"
                                            BorderThickness="0"
                                            Click="OnRemoveExerciseClick"
                                            Content="REMOVE"
                                            Foreground="White"
                                            Style="{StaticResource SimpleButton}" />

                                    <Button Grid.Column="2"
                                            HorizontalAlignment="Stretch"
                                            VerticalAlignment="Stretch"
                                            Background="{StaticResource GymBlue}"
                                            BorderBrush="{StaticResource GymBlue}"
                                            BorderThickness="0"
                                            Click="OnSaveClick"
                                            Content="SAVE"
                                            Foreground="White"
                                            Style="{StaticResource SimpleButton}" />

                                </Grid>
                            </Grid>
                        </Grid>

                    </Flyout>
                </AppBarButton.Flyout>
            </AppBarButton>
            <AppBarButton Click="OnReorderClicked"
                          Icon="Edit"
                          Label="REORDER" />
            <AppBarButton Click="OnBackupClick"
                          Icon="Send"
                          Label="BACKUP" />
        </CommandBar>
    </Page.BottomAppBar>
</Page>
